package reflect;

import java.lang.reflect.Method;

public class ReflectDemo05 {
    public static void main(String[] args) throws Exception {
        //反射机制创建
        Class cla = Class.forName("reflect.Person");
        Object object = cla.newInstance();
        //Method method = cla.getMethod("say",String.class);
        //调用另外一个方法，并要传入索要传入参数的类型
        Method method = cla.getMethod("say", String.class, int.class);
        //调用
        //method.invoke(object,"heihei");
        method.invoke(object,"xiaohei", 12);
    }
}
